package tianwang.util;

import java.util.HashMap;
import java.util.Map;

import tianwang.utils.dict.CommonIDictionary;
import tianwang.utils.dict.CommonIIDictionary;
import tianwang.utils.dict.Dictionary;
import tianwang.utils.dict.DictionaryStore;
import tianwang.utils.dict.DictionaryStoreImpl;
import tianwang.utils.dict.EmptyDictionary;
import tianwang.utils.dict.LevelDaoDict;

public class DictionaryUtil {
	public static String LEVEL_DAO_DICT = "leveldao";
	
	/**
	 * 词汇密度有关
	 */
	public static String EMPTY_DICTIONARY = "EmptyDictionary";
	
	public static String COMMON_I_DICTIONARY = "CommonIDictionary";
	public static String COMMON_II_DICTIONARY = "CommonIIDictionary";
	
	private static DictionaryStoreImpl store = null;
	public static DictionaryStore getDictionarys(){
		if(store == null){
			store = new DictionaryStoreImpl();
			
			Map<String, Dictionary> dicts = new HashMap<String,Dictionary>();
			
			dicts.put(LEVEL_DAO_DICT, new LevelDaoDict());
			dicts.put(EMPTY_DICTIONARY, new EmptyDictionary());
			dicts.put(COMMON_I_DICTIONARY, new CommonIDictionary());
			dicts.put(COMMON_II_DICTIONARY, new CommonIIDictionary());
			
			store.setDicts(dicts);
		}
		
		return store;
	}
	
	public static Dictionary getDict(String name){
		DictionaryStore store = getDictionarys();
		return store.borrow(name);
	}
}
